package leetcode.l0526;

/**
 * @author Retain
 * @date 2021/5/26 18:09
 */
public class Easy_对称二叉树_101 {
    public boolean isSymmetric(TreeNode root) {
        return isSymmetric(root.left, root.right);
    }

    private boolean isSymmetric(TreeNode left, TreeNode right) {
        if (left == null && right == null) {
            return true;
        }
        if (left == null || right == null) {
            return false;
        }
        // 递归判断左子树的右子树值 和 右子树的左子树值是否相等 以及 左子树的左子树值 与 右子树的右子树值是否相等
        return left.val == right.val && isSymmetric(left.left, right.right) && isSymmetric(left.right, right.left);
    }
}
